<?
$q = 'select * from hl_groups order by id';
if (! ($sth = mysql_query ( $q ))) {
	exit ( mysql_error () );
}
$listings = array ();
while ( $row = mysql_fetch_array ( $sth ) ) {
	$q = 'select count(*) as cnt from hl_listings where group_id=' . $row ['id'];
	if (! ($sth1 = mysql_query ( $q ))) {
		exit ( mysql_error () );
	}
	
	$row1 = mysql_fetch_array ( $sth1 );
	$row ['cnt'] = $row1 ['cnt'];
	array_push ( $listings, $row );
}

?>

<form method=post>
<input type="hidden" name="a" value="update_groups">
<table cellspacing=1 cellpadding=1 border=0 width=100% bordercolor="red">
	<tr>
		<td colspan=3><b>Groups:</b></td>
	</tr>
	<tr>
		<td class=title width=1%><b>Status</b> </td>
		<td class=title width=1% nowrap><b>On Index</b> </td>
		<td class=title width=1% nowrap><b>On New</b> </td>
		<td class=title><b>Group name</b> </td>
		<td class=title><b>Type</b> </td>
		<td class=title><b>Listings</b> </td>
		<td class=title width=1%><b>-</b> </td>
	</tr>
<?php
if (0 < sizeof ( $listings )) {
	foreach ( $listings as $line ) {
		echo '<tr>
 <td align=center><input type="checkbox" name="status[';
		echo $line ['id'];
		echo ']" value=1 ';
		echo ($line ['status'] ? 'checked' : '');
		echo '></td>
 <td align=center><input type="checkbox" name="onindex[';
		echo $line ['id'];
		echo ']" value=1 ';
		echo ($line ['onindex'] ? 'checked' : '');
		echo '></td>
 <td align=center><input type="checkbox" name="onnew[';
		echo $line ['id'];
		echo ']" value=1 ';
		echo ($line ['onnew'] ? 'checked' : '');
		echo '></td>
 <td><a href="?a=listings&gid=';
		echo $line ['id'];
		echo '">';
		echo $line ['name'];
		echo '</a></td>
 <td>';
		echo $line ['type'];
		echo '</td>
 <td align=center>';
		echo $line ['cnt'];
		echo '</td>
 <td class=menutxt align=right nowrap><a href=?a=edit_group&id=';
		echo $line ['id'];
		echo '>[edit]</a></td>
</tr> ';
	}
	
	echo '<tr>
<td colspan=5 align="center">
	<br/>
	<input type="submit" value="Update" class=sbmt></td>
</tr>
';
} else {
	echo '<tr>
 <td bgcolor=FFF9B3 colspan=4>No Groups found</td>
</tr>
';
}
?>
</table>
</form>
<br>

